﻿using System;

namespace Socium.Domain.Tests {
	[Serializable]
	public struct CountRange {
		readonly int _minimum;
		readonly int _maximum;

		public CountRange(int minimum, int maximum) {
			if (minimum > maximum)
				throw new ArgumentException("minimum > maximum");

			_minimum = minimum;
			_maximum = maximum;
		}

		public CountRange(int single_value)
			: this(single_value, single_value) {
		}

		public static CountRange ExactlyOne {
			get { return new CountRange(1, 1); }
		}

		public int Maximum {
			get { return _maximum; }
		}

		public int Minimum {
			get { return _minimum; }
		}

		public bool ContainsValue(int value) {
			return value >= Minimum && value <= Maximum;
		}

		public override string ToString() {
			return string.Format("[{0}, {1}]", Minimum, Maximum);
		}

		public bool IsOne {
			get { return _minimum == 1 && _maximum == 1; }
		}
	}
}
